package com.heima.article.service.Impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.article.pojos.ApArticleConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {


    @Autowired
    private ApArticleConfigMapper articleConfigMapper;

    @Override
    /**
     * 修改文章配置
     * @param map
     */
    public void updateByMap(Map map){

        boolean flag = true;

        Object enable = map.get("enable");
        if(enable != null && enable.equals("1")){
            flag = false;
        }

        // 修改文章的上下架配置
        update(Wrappers.<ApArticleConfig>lambdaUpdate()
                .eq(ApArticleConfig::getArticleId,map.get("id"))
                .set(ApArticleConfig::getIsDown,flag));

    }

}
